import smtplib
from email.mime.text import MIMEText
from email.header import Header

sender = "1161127823@qq.com"  # “我”的邮箱
password = "tobkujbhmxekhgac"  # 密码
receiver = "1161127823@qq.com"  # 接收者邮箱
subject = "hello"  # 邮件标题
words = "world"  # 邮件正文
smtpserver = 'smtp.qq.com'

msg = MIMEText(words, 'plain', 'utf-8')  # 中文需参数‘utf-8'，单字节字符不需要
msg['Subject'] = Header(subject, 'utf-8')  # 邮件标题
msg['from'] = sender  # 发信人地址
msg['to'] = receiver  # 收信人地址

smtp = smtplib.SMTP()
smtp.connect('smtp.qq.com')
smtp.login(sender, password)
smtp.sendmail(sender, receiver, msg.as_string())  # 这行代码解决的下方554的错误
smtp.quit()
print("邮件发送成功!")

